using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DataTransferObject;
using Business;

namespace Presentation.UserControlls
{
    public partial class UC_SachDaMuon : UserControl
    {
        clsThuThuBUS ThuThuBUS = new clsThuThuBUS();
        DataTable tbl = new DataTable();
        int tongcong;

        public UC_SachDaMuon()
        {
            InitializeComponent();
        }

        private void UC_SachDaMuon_Load(object sender, EventArgs e)
        {

            tbl = ThuThuBUS.SachBUS.ThongKeSachDaMuon();
            tongcong = 0;

            HienThiListView(tbl);
            lbltongcong.Text = Convert.ToString(tongcong);
        }

        private void HienThiListView(DataTable tbl)
        {
            int i = 1;
            ListViewItem lvwitem = new ListViewItem();
            lvwthongkesachdamuon.Items.Clear();
            foreach (DataRow dr in tbl.Rows)
            {
                string trangthai = dr["TrangThaiMT"].ToString();
                if (trangthai == "Đang Mượn")
                {
                    tongcong = tongcong + 1;
                    lvwitem = new ListViewItem();
                    lvwitem.Text = Convert.ToString(i++);
                    lvwitem.SubItems.Add(dr["DKCB"].ToString());
                    lvwitem.SubItems.Add(dr["TenTuaSach"].ToString());
                    lvwitem.SubItems.Add(dr["Gia"].ToString());
                    //lvwitem.SubItems.Add(dr["TrangThaiMT"].ToString());
                    lvwthongkesachdamuon.Items.Add(lvwitem);
                }

            }


        }

        private void buttonX1_Click(object sender, EventArgs e)
        {
            FromInAn.FrmTKSachDangMuon sachdangmuon = new Presentation.FromInAn.FrmTKSachDangMuon();
            sachdangmuon.Show();
        }
    }
}
